Types and type systems are ubiquitous aspects of computer programming although different languages may use different terminology. A type is a classification of data and assigning a type gives meaning to a sequence of bits. A sequence of bits does not, by itself, provide a distinction between memory addresses, instruction code, integers, floating point numbers, characters, and other purposes for the sequence. Associating a sequence of bits with a type informs computer programs how that sequence of bits should be understood. Other entities, such as objects, modules, communication channels, dependencies, or even types themselves, can become associated with a type.
A type system may be defined as “a tractable syntactic framework for classifying phrases according to the kinds of values they compute.” A type system associates a type with each computed value and includes a set of rules or constraints for the type. A particular type system determines what constitutes a type error. In general, one aim of the type system is to prevent operations expecting a certain kind of value being used with values for which that operation does not make sense. Type systems are often specified as part of programming languages—and built into the interpreters and compilers for them—although they can also be implemented as optional tools.
The process of verifying and enforcing type constraints, often referred to as type checking, may occur either at compile-time or run-time. A programming language uses static typing when type checking is performed during compile-time as opposed to run-time. Static typing is a limited form of program verification, and it allows many type errors to be caught early in the development cycle. Static type checkers evaluate the type information that can be determined at compile time, but are able to verify that the checked conditions hold for further possible executions of the program. Applications created with static languages can be made more efficient, such as faster execution and/or taking reduced memory, by omitting runtime type checks and enabling other optimizations.
A programming language is dynamically typed when the majority of type checking is performed at run-time. Values in dynamic typing have types but variables do not, and a variable can refer to a value of any type. In one example, dynamic languages make excellent scripting languages. Applications created with dynamic languages can be relatively easily extended with new commands and functionality. Dynamic languages are also frequently used for creating Web sites and test harnesses, maintaining server farms, developing various utilities, and performing data transformations.